try:
    import winreg
except:
    class WindowsError(Exception): pass
import os
import platform

def get_interfaces():
    interfaces = []
    current_type = None
    eth_num = 0
    wlan_num = 0
    stream = os.popen('ipconfig /all') if platform.system() == 'Windows' else open('ipconfig.txt')
    for line in stream:
        if 'fizyczny' in line or 'Physical' in line:
            if current_type:
                mac = line.split(':', 1)[1].strip().replace('-', ':')
                if not mac.startswith('00:00:00:00:00'):
                    interfaces.append((current_type, mac))
        if 'Local Area Connection' in line or 'czenie lokalne' in line:
            current_type = 'eth%d' % eth_num
            eth_num += 1
        if 'sieci bezprzewodowej' in line:
            current_type = 'wlan%d' % wlan_num
            wlan_num += 1
    return interfaces

def read_registry(path):
    root, rest = path.split('\\', 1)
    sub_key, chain = rest.split('\\', 1)
    key = getattr(winreg, root)
    for name in chain.split('\\'):
        try:
            key = winreg.OpenKey(key, name)
        except:
            raise WindowsError('failed to open %s' % name)
    return winreg.QueryValueEx(key, sub_key)[0]

def get_key():
    try:
        return read_registry(r'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion').decode('ascii')
    except WindowsError:
        return 'fail'

if __name__ == '__main__':
    print(get_interfaces())
    print(get_key())